cmake_minimum_required(VERSION 3.0)
project(OCR)

set(CMAKE_CXX_STANDARD 17)

set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda)
find_package(CUDA REQUIRED)

find_package(OpenCV REQUIRED)

set(TRT_ROOT_DIR /home/ssy/Downloads/TensorRT-7.2.1.6)
add_definitions(-DTRT_EXEC_PATH=${TRT_ROOT_DIR})

include_directories(${TRT_ROOT_DIR}/include)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

link_directories(${TRT_ROOT_DIR}/lib)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs)
link_directories(/usr/local/cuda/lib64)
link_directories(/usr/lib64)
add_definitions(-DUSE_FP16)

file(GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.h ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
message(${SOURCE_FILES})

add_library(func SHARED ${SOURCE_FILES})

target_link_libraries(func ${OpenCV_LIBS} ${CUDA_LIBRARIES} nvinfer nvinfer_plugin nvonnxparser nvparsers)
install(TARGETS func LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/libs)

add_executable(${PROJECT_NAME} demo.cpp)

target_link_libraries(${PROJECT_NAME} func ${OpenCV_LIBS} ${CUDA_LIBRARIES} nvinfer nvinfer_plugin nvonnxparser nvparsers)
